/*
 * CcLex.h
 *
 *  Created on: 2012/04/28
 *      Author: guanxiaoying
 */

#ifndef CCLEX_H_
#define CCLEX_H_

/*  ULONG_NODEKIND  */
/************************************************************************/
/**********	字句解析の分類ｺｰﾄﾞ	 stExpressionInfo  ulNodeKind******************/
/************************************************************************/
/*_____[ 分類ｺｰﾄﾞﾏｽｸﾊﾟﾀｰﾝ ]_____________________________________________*/
#define	xLEXMASK_LARGE		0xFF000000UL	/* 大分類ﾏｽｸﾊﾟﾀｰﾝ	*/
#define	xLEXMASK_MIDDLE		0x00FF0000UL	/* 中分類ﾏｽｸﾊﾟﾀｰﾝ	*/
#define	xLEXMASK_DETAIL		0x0000FFFFUL	/* 詳細ｺｰﾄﾞﾏｽｸﾊﾟﾀｰﾝ	*/

/*_____[ 大分類ｺｰﾄﾞ ]___________________________________________________*/
#define xLEXBIT_CALC		0x01000000UL	/* 演算子			*/
#define xLEXBIT_CTRL		0x02000000UL	/* 制御命令			*/
#define xLEXBIT_DEF			0x04000000UL	/* 定義ｴﾘｱ			*/
#define xLEXBIT_CONST		0x08000000UL	/* 定数				*/
#define xLEXBIT_OTHER		0x10000000UL	/* その他			*/

/*_____[ 中分類ｺｰﾄﾞ ]___________________________________________________*/
#define xLEXBIT_TYPE		0x00010000UL	/* 定義ｴﾘｱ:型名			*/
#define xLEXBIT_CLASS		0x00020000UL	/* 定義ｴﾘｱ:記憶ｸﾗｽ		*/
#define xLEXBIT_ADJ			0x00040000UL	/* 定義ｴﾘｱ:性質修飾		*/
#define xLEXBIT_SIZE		0x00080000UL	/* 定義ｴﾘｱ:ｻｲｽﾞ修飾		*/
#define xLEXBIT_SIGN		0x00100000UL	/* 定義ｴﾘｱ:符号修飾		*/

/*_____[ 詳細ｺｰﾄﾞ:演算子 ]______________________________________________*/
#define xLEX_DIV		(xLEXBIT_CALC|0x0001UL)		/* /		*/
#define xLEX_DIVEQU		(xLEXBIT_CALC|0x0002UL)		/* /=		*/
#define xLEX_LESSEQU	(xLEXBIT_CALC|0x0003UL)		/* <=		*/
#define xLEX_SHLEQU		(xLEXBIT_CALC|0x0004UL)		/* <<=		*/
#define xLEX_SHL		(xLEXBIT_CALC|0x0005UL)		/* <<		*/
#define xLEX_LESS		(xLEXBIT_CALC|0x0006UL)		/* <		*/
#define xLEX_GRTREQU	(xLEXBIT_CALC|0x0007UL)		/* >=		*/
#define xLEX_SHREQU		(xLEXBIT_CALC|0x0008UL)		/* >>=		*/
#define xLEX_SHR		(xLEXBIT_CALC|0x0009UL)		/* >>		*/
#define xLEX_GRTR		(xLEXBIT_CALC|0x000AUL)		/* >		*/
#define xLEX_MEMREFP	(xLEXBIT_CALC|0x000BUL)		/* ->		*/
#define xLEX_DEC		(xLEXBIT_CALC|0x000CUL)		/* --val	*/
#define xLEX_SUBEQU		(xLEXBIT_CALC|0x000DUL)		/* -=		*/
#define xLEX_MINUS		(xLEXBIT_CALC|0x000EUL)		/* -		*/
#define xLEX_SUB		(xLEXBIT_CALC|0x000FUL)		/* -		*/
#define xLEX_EQUEQU		(xLEXBIT_CALC|0x0010UL)		/* ==		*/
#define xLEX_EQU		(xLEXBIT_CALC|0x0011UL)		/* =		*/
#define xLEX_NOTEQU		(xLEXBIT_CALC|0x0012UL)		/* !=		*/
#define xLEX_NOT		(xLEXBIT_CALC|0x0013UL)		/* !		*/
#define xLEX_LOR		(xLEXBIT_CALC|0x0014UL)		/* ||		*/
#define xLEX_OREQU		(xLEXBIT_CALC|0x0015UL)		/* |=		*/
#define xLEX_OR			(xLEXBIT_CALC|0x0016UL)		/* |		*/
#define xLEX_LAND		(xLEXBIT_CALC|0x0017UL)		/* &&		*/
#define xLEX_ANDEQU		(xLEXBIT_CALC|0x0018UL)		/* &=		*/
#define xLEX_AND		(xLEXBIT_CALC|0x0019UL)		/* &		*/
#define xLEX_ADR		(xLEXBIT_CALC|0x001AUL)		/* &		*/
#define xLEX_INC		(xLEXBIT_CALC|0x001BUL)		/* ++val	*/
#define xLEX_ADDEQU		(xLEXBIT_CALC|0x001CUL)		/* +=		*/
#define xLEX_PLUS		(xLEXBIT_CALC|0x001DUL)		/* +		*/
#define xLEX_ADD		(xLEXBIT_CALC|0x001EUL)		/* +		*/
#define xLEX_COMMA		(xLEXBIT_CALC|0x001FUL)		/* ,		*/
#define xLEX_MULEQU		(xLEXBIT_CALC|0x0020UL)		/* *=		*/
#define xLEX_ASTERISK	(xLEXBIT_CALC|0x0021UL)		/* *		*/
#define xLEX_MUL		(xLEXBIT_CALC|0x0022UL)		/* *		*/
#define xLEX_NEG		(xLEXBIT_CALC|0x0023UL)		/* ~		*/
#define xLEX_MODEQU		(xLEXBIT_CALC|0x0024UL)		/* %=		*/
#define xLEX_MOD		(xLEXBIT_CALC|0x0025UL)		/* %		*/
#define xLEX_XOREQU		(xLEXBIT_CALC|0x0026UL)		/* ^=		*/
#define xLEX_XOR		(xLEXBIT_CALC|0x0027UL)		/* ^		*/
#define xLEX_BANK		(xLEXBIT_CALC|0x0028UL)		/* $		*/
#define xLEX_QUESTION	(xLEXBIT_CALC|0x0029UL)		/* ?		*/
#define xLEX_OPENARRAY	(xLEXBIT_CALC|0x002AUL)		/* [		*/
#define xLEX_CLOSEARRAY	(xLEXBIT_CALC|0x002BUL)		/* ]		*/
#define xLEX_OPENPAREN	(xLEXBIT_CALC|0x002CUL)		/* (		*/
#define xLEX_CLOSEPAREN	(xLEXBIT_CALC|0x002DUL)		/* )		*/
#define xLEX_MEMREF		(xLEXBIT_CALC|0x002EUL)		/* .		*/
#define xLEX_SIZEOF		(xLEXBIT_CALC|0x002FUL)		/* sizeof	*/
#define xLEX_POSTINC	(xLEXBIT_CALC|0x0030UL)		/* val++	*/
#define xLEX_POSTDEC	(xLEXBIT_CALC|0x0031UL)		/* val--	*/
#define xLEX_FUNCTION	(xLEXBIT_CALC|0x0032UL)		/* 関数呼び出し	*/
#define xLEX_CAST		(xLEXBIT_CALC|0x0033UL)		/* ｷｬｽﾄ		*/
#define xLEX_ARG		(xLEXBIT_CALC|0x0034UL)		/* 関数呼び出しの実引数	*/
#define xLEX_COLON		(xLEXBIT_CALC|0x0035UL)		/* :		*/

/*_____[ 詳細ｺｰﾄﾞ:制御命令 ]____________________________________________*/
#define xLEX_IF			(xLEXBIT_CTRL|0x0001UL)		/* if		*/
#define xLEX_BREAK		(xLEXBIT_CTRL|0x0002UL)		/* break	*/
#define xLEX_CASE		(xLEXBIT_CTRL|0x0003UL)		/* case		*/
#define xLEX_CONTINUE	(xLEXBIT_CTRL|0x0004UL)		/* continue	*/
#define xLEX_DEFAULT	(xLEXBIT_CTRL|0x0005UL)		/* default	*/
#define xLEX_DO			(xLEXBIT_CTRL|0x0006UL)		/* do		*/
#define xLEX_ELSE		(xLEXBIT_CTRL|0x0007UL)		/* else		*/
#define xLEX_FOR		(xLEXBIT_CTRL|0x0008UL)		/* for		*/
#define xLEX_GOTO		(xLEXBIT_CTRL|0x0009UL)		/* goto		*/
#define xLEX_RETURN		(xLEXBIT_CTRL|0x000AUL)		/* return	*/
#define xLEX_SWITCH		(xLEXBIT_CTRL|0x000BUL)		/* switch	*/
#define xLEX_WHILE		(xLEXBIT_CTRL|0x000CUL)		/* while	*/

/*_____[ 詳細ｺｰﾄﾞ:定義ｴﾘｱ ]_____________________________________________*/
#define xLEX_INT		(xLEXBIT_DEF|xLEXBIT_TYPE |0x0001UL)/* int	*/
#define xLEX_CHAR		(xLEXBIT_DEF|xLEXBIT_TYPE |0x0002UL)/* char	*/
#define xLEX_DOUBLE		(xLEXBIT_DEF|xLEXBIT_TYPE |0x0003UL)/* double	*/
#define xLEX_FLOAT		(xLEXBIT_DEF|xLEXBIT_TYPE |0x0004UL)/* float	*/
#define xLEX_VOID		(xLEXBIT_DEF|xLEXBIT_TYPE |0x0005UL)/* void	*/
#define xLEX_AUTO		(xLEXBIT_DEF|xLEXBIT_CLASS|0x0006UL)/* auto	*/
#define xLEX_EXTERN		(xLEXBIT_DEF|xLEXBIT_CLASS|0x0007UL)/* extern	*/
#define xLEX_REGISTER	(xLEXBIT_DEF|xLEXBIT_CLASS|0x0008UL)/* register	*/
#define xLEX_STATIC		(xLEXBIT_DEF|xLEXBIT_CLASS|0x0009UL)/* static	*/
#define xLEX_TYPEDEF	(xLEXBIT_DEF|xLEXBIT_CLASS|0x000AUL)/* typedef	*/
#define xLEX_INTERRUPT	(xLEXBIT_DEF|xLEXBIT_CLASS|0x000BUL)/* interrupt*/
#define xLEX_CONST		(xLEXBIT_DEF|xLEXBIT_ADJ  |0x000CUL)/* const	*/
#define xLEX_VOLATILE	(xLEXBIT_DEF|xLEXBIT_ADJ  |0x000DUL)/* volatile	*/

#define xLEX_ENUM		(xLEXBIT_DEF|              0x000EUL)/* enum	*/
#define xLEX_STRUCT		(xLEXBIT_DEF|              0x000FUL)/* struct	*/
#define xLEX_UNION		(xLEXBIT_DEF|              0x0010UL)/* union	*/
#define xLEX_SHORT		(xLEXBIT_DEF|xLEXBIT_SIZE |0x0011UL)/* short	*/
#define xLEX_LONG		(xLEXBIT_DEF|xLEXBIT_SIZE |0x0012UL)/* long	*/
#define xLEX_SIGNED		(xLEXBIT_DEF|xLEXBIT_SIGN |0x0013UL)/* signed	*/
#define xLEX_UNSIGNED	(xLEXBIT_DEF|xLEXBIT_SIGN |0x0014UL)/* unsigned	*/
#define xLEX_INLINE	(xLEXBIT_DEF|0x0015UL)	/* ｲﾝﾗｲﾝｱｾﾝﾌﾞﾗ	*/
#define xLEX_INLINEASM	(xLEXBIT_DEF|0x0016UL)	/* ｲﾝﾗｲﾝｱｾﾝﾌﾞﾗ	*/
#define xLEX_FAR	(xLEXBIT_DEF|0x0017UL)	/* ｲﾝﾗｲﾝｱｾﾝﾌﾞﾗ	*/
#define xLEX_NEAR	(xLEXBIT_DEF|0x0018UL)	/* ｲﾝﾗｲﾝｱｾﾝﾌﾞﾗ	*/
#define xLEX_COMPLEX  (xLEXBIT_DEF|xLEXBIT_TYPE |0x0019UL)/* complex	*/
#define xLEX_IMAGINART  (xLEXBIT_DEF|xLEXBIT_TYPE |0x001AUL)/* imaginary	*/
#define xLEX_RESTRICT   (xLEXBIT_DEF|xLEXBIT_ADJ  |0x001BUL)/* restrict	*/
#define xLEX_ATTRIBUTE   (xLEXBIT_DEF|xLEXBIT_ADJ  |0x001CUL)/* __attribute__	*/

/*_____[ 詳細ｺｰﾄﾞ:定数 ]________________________________________________*/
#define xLEX_CONSTCHAR	  (xLEXBIT_CONST|0x0001UL)	/* 整数値	*/
#define xLEX_CONSTVALUE   (xLEXBIT_CONST|0x0002UL)	/* 整数値	*/
#define xLEX_CONSTSTR	  (xLEXBIT_CONST|0x0009UL)	/* 文字列	*/

/*_____[ 詳細ｺｰﾄﾞ:その他 ]______________________________________________*/
#define xLEX_ENDOFFILE	(xLEXBIT_OTHER|0x0001UL)	/* EOF		*/
#define xLEX_SEMICOLON	(xLEXBIT_OTHER|0x0002UL)	/* ;		*/

#define xLEX_OPENBLOCK	(xLEXBIT_OTHER|0x0004UL)	/* {		*/
#define xLEX_CLOSEBLOCK	(xLEXBIT_OTHER|0x0005UL)	/* }		*/
#define xLEX_ELLIPSIS	(xLEXBIT_OTHER|0x0006UL)	/* ...		*/
#define xLEX_QUOTCHAR	(xLEXBIT_OTHER|0x0007UL)	/* '		*/
#define xLEX_QUOTSTR	(xLEXBIT_OTHER|0x0008UL)	/* "		*/
#define xLEX_SYMBOL		(xLEXBIT_OTHER|0x0009UL)	/* ｼﾝﾎﾞﾙ	*/
#define xLEX_UNDEFINED	(xLEXBIT_OTHER|0x000AUL)	/* 空ﾄｰｸﾝ	*/
#define xLEX_SKIPTOKEN	(xLEXBIT_OTHER|0x000BUL)	/* 無視するﾄｰｸﾝ	*/
#define xLEX_PRAGMABEGIN	(xLEXBIT_OTHER|0x000CUL)	/* pragma start	*/
#define xLEX_PRAGMAEND	(xLEXBIT_OTHER|0x000DUL)	/* pragma end	*/

#define xLEX_GBLLINKAGE		(xLEXBIT_OTHER|0x000DUL)	/* ｼﾝﾎﾞﾙ	*/
#define xLEX_LINKAGE		(xLEXBIT_OTHER|0x000EUL)	/* ｼﾝﾎﾞﾙ	*/
#define xLEX_WARNINGLINKAGE	(xLEXBIT_OTHER|0x000FUL)	/* ｼﾝﾎﾞﾙ	*/
#define xLEX_TYPENAME		(xLEXBIT_OTHER|0x0010UL)	/* ｼﾝﾎﾞﾙ	*/
#define xLEX_PAREN			(xLEXBIT_OTHER|0x0012UL)	/* ｼﾝﾎﾞﾙ	*/

//BOOL CcLexIsDeclarationKeyword(AST astToken);
#define CcLexIsDeclarationKeyword(token)  	( (stLexTokenAccess.tokenKind.get(token) & xLEXBIT_DEF) != 0 )
/***********************************************************
 * initial
 ***********************************************************/
extern VOID CcLexInit(AST astTranslation) ;
/******************************************************************
 * return the current token.
 *******************************************************************/
extern AST CcLexGetCurrToken(VOID);
/******************************************************************
 * return the next token of current token.
 * return a xLEX_ENDOFFILE token when finished.
 *******************************************************************/
extern AST CcLexGetNextToken(VOID);
/**************************************
 * Get the token backwards.
 **************************************/
extern AST CcLexGetLF(S4 num);
/**************************************
 * Get the token ahead.
 **************************************/
extern AST CcLexGetRT(S4 num);
/**************************************
 * Jump back.
 **************************************/
extern VOID CcLexBackto(AST token);
/**************************************
 * get the final one
 **************************************/
extern AST CcLexGetLastOne(VOID );
#endif /* CCLEX_H_ */
